﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.Core.Runtime.Messages;
using PServiceBus.Core.Interface;
using PServiceBus.Core.Runtime.Configuration;

namespace PServiceBus.Core.Manager {
    public class ResequenceMessageManager {
        private static IObjectManager<ResequenceMessage> _messages;

        private static IObjectManager<ResequenceMessage> Messages {
            get {
                if (_messages == null)
                    _messages = ObjectManager<ResequenceMessage>.Create(ConfigurationProvider.ServiceBusConfig.ResequenceMessageAddress);
                return _messages;
            }
        }

        /// <summary>
        /// Add new message to the underlying data store
        /// </summary>
        /// <param name="message"></param>
        public static void Attach(ResequenceMessage message) {
            Messages.Attach(message);
        }

        /// <summary>
        /// Add new messages to the underlying data store
        /// </summary>
        /// <param name="messages"></param>
        public static void AttachMany(IEnumerable<ResequenceMessage> messages) {
            Messages.AttachMany(messages);
        }
    }
}
